/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package 解析.node.slicenode;

import 解析.Matcher;

/**
 *
 * @author yanxi
 */
public class SliceU extends SliceNode {

    public SliceU(int[] buf) {
        super(buf);
    }

    @Override
    public boolean match(Matcher matcher, int i, CharSequence seq) {
        int[] buf = buffer;
        int len = buf.length;
        for (int j = 0; j < len; j++) {
            if ((i + j) >= matcher.to) {
                matcher.hitEnd = true;
                return false;
            }
            int c = seq.charAt(i + j);
            if (buf[j] != c
                    && buf[j] != Character.toLowerCase(Character.toUpperCase(c))) {
                return false;
            }
        }
        return next.match(matcher, i + len, seq);
    }
}
